<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>系统设置- 系统设置</title>
    <meta name="keywords" content="">
    <meta name="description" content="">
    <link rel="shortcut icon" href="../favicon.ico">
    <link href="__PUBLIC__/css/bootstrap.min.css?v=3.3.6" rel="stylesheet">
    <link href="__PUBLIC__/css/font-awesome.css?v=4.4.0" rel="stylesheet">
    <link href="__PUBLIC__/css/plugins/iCheck/custom.css" rel="stylesheet">
    <link href="__PUBLIC__/css/animate.css" rel="stylesheet">
    <link href="__PUBLIC__/css/style.css?v=4.1.0" rel="stylesheet">
    <link rel="stylesheet" href="__PUBLIC__/css/liandong.css"/>
    <link href="__PUBLIC__/Widget/webuploader/0.1.5/webuploader.css" rel="stylesheet" type="text/css"/>
    <script src="__PUBLIC__/js/plugins/layer/laydate/laydate.js"></script>
    <style>
        .img {
            width: auto !important;
            max-width: 128px;
            max-height: 128px;
        }

        .img_default {
            width: auto !important;
            max-width: 128px;
            max-height: 128px;
        }
    </style>
</head>
<body class="gray-bg">
<div class="wrapper wrapper-content animated fadeInRight">
    <div class="row">
        <div class="col-sm-12">
            <div class="ibox float-e-margins">
                <div class="ibox-title">
                    <h5>系统设置-
                        <small>系统设置</small>
                    </h5>
                </div>
                <div class="ibox-content">
                    <form method="post" class="form-horizontal" onsubmit="return false">
                        <div class="form-group">
                            <label class="col-sm-2 control-label">金币换算</label>
                            <div class="col-sm-10">
                                1元（人民币） =
                                <div class="col-sm-2" style="float: none; display: inline-block;">
                                    <input type="text" class="form-control int" value="<{$ratio}>"
                                           placeholder="请输入没有小数位的数字" id="txtratio">
                                </div>
                                金币
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-2 control-label">分享收益比例</label>
                            <div class="col-sm-10">
                                1元（人民币） =
                                <div class="col-sm-2" style="float: none; display: inline-block;">
                                    <input type="text" class="form-control int" value="<{$share_ratio}>"
                                           placeholder="请输入没有小数位的数字" id="txtshare_ratio">
                                </div>
                                金币
                            </div>
                        </div>
                        <div class="form-group" style="display: none;">
                            <label class="col-sm-2 control-label">默认加载图片</label>
                            <div class="col-sm-10">
                                <div class="btn-file">
                                    <button class="btn btn-primary">上传图片</button>
                                    <input id="logoimg" type="file" name="logoimg">
                                    <input id="logosrc" type="hidden" name="logosrc" value="<{$user_logo}>">
                                </div>
                                <div class="product_img">
                                    <if condition="$id gt 0">
                                        <img id="inputfile-img" alt='未找到图片' src="<{$img_default}>" style="width:128px">
                                        <else/>
                                        <img id="inputfile-img" alt='未找到图片' src="__PUBLIC__/img/webuploader.png"
                                             style="width:128px">
                                    </if>
                                </div>
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-2 control-label">注册邀请语</label>
                            <div class="col-sm-10">
                                <input type="text" class="form-control" value="<{$invite_word}>"
                                       placeholder="请输入邀请语（输入“{1}”符号可代替邀请赠送金币）" id="txtinviteword">
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-2 control-label">注册赠送金币</label>
                            <div class="col-sm-10">
                                <input type="text" class="form-control int" value="<{$init_gold}>"
                                       placeholder="请输入没有小数位的数字" id="txtinitgold">
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-2 control-label">邀请赠送金币</label>
                            <div class="col-sm-10">
                                <input type="text" class="form-control int" value="<{$invite_gold}>"
                                       placeholder="请输入没有小数位的数字" id="txtinvitegold">
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-2 control-label">消息发送价格（金币）/条</label>
                            <div class="col-sm-10">
                                <input type="text" class="form-control int" value="<{$message_gold}>"
                                       placeholder="请输入没有小数位的数字" id="txtmessagegold">
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-2 control-label">视频通话价格（金币）/分钟</label>
                            <div class="col-sm-10">
                                <input type="text" class="form-control int" value="<{$video_gold}>"
                                       placeholder="请输入没有小数位的数字" id="txtvideogold">
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-2 control-label">月满消费（RMB）与新人主播免费聊</label>
                            <div class="col-sm-10">
                                <input type="text" class="form-control int" value="<{$free_cumulative}>"
                                       placeholder="请输入没有小数位的数字" id="txtfreecumulative">
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-2 control-label">相册审核开关</label>
                            <div class="col-sm-10">
                                <select class="form-control" id="ddlimgsidswitch">
                                    <volist name="imgsidswitcharr" id="imgsidswitcharr">
                                        <option value="<{$imgsidswitcharr.value}>"
                                        <{$imgsidswitcharr.switch_selected}>><{$imgsidswitcharr.text}></option>
                                    </volist>
                                </select>
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-2 control-label">视频通话录制开关</label>
                            <div class="col-sm-10">
                                <select class="form-control" id="ddlvideoswitch">
                                    <volist name="videoswitcharr" id="videoswitcharr">
                                        <option value="<{$videoswitcharr.value}>"
                                        <{$videoswitcharr.switch_selected}>><{$videoswitcharr.text}></option>
                                    </volist>
                                </select>
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-2 control-label">第三方登录开关</label>
                            <div class="col-sm-10">
                                <div style="padding: 15px 0; border:1px solid #cfdadd;">
                                    <div class="form-group">
                                        <label class="col-sm-2 control-label">QQ登录</label>
                                        <div class="col-sm-9">
                                            <select class="form-control" id="ddlqqswitch">
                                                <volist name="qqswitcharr" id="qqswitcharr">
                                                    <option value="<{$qqswitcharr.value}>"
                                                    <{$qqswitcharr.switch_selected}>><{$qqswitcharr.text}></option>
                                                </volist>
                                            </select>
                                        </div>
                                    </div>
                                    <div class="form-group">
                                        <label class="col-sm-2 control-label">微信登录</label>
                                        <div class="col-sm-9">
                                            <select class="form-control" id="ddlwxswitch">
                                                <volist name="wxswitcharr" id="wxswitcharr">
                                                    <option value="<{$wxswitcharr.value}>"
                                                    <{$wxswitcharr.switch_selected}>><{$wxswitcharr.text}></option>
                                                </volist>
                                            </select>
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </div>

                        <div class="hr-line-dashed"></div>
                        <div class="form-group">
                            <label class="col-sm-2 control-label">短信配置参数</label>
                            <div class="col-sm-10">
                                <div style="padding: 15px 0; border:1px solid #cfdadd;">
                                    <div class="form-group">
                                        <label class="col-sm-2 control-label">accountSid</label>
                                        <div class="col-sm-9">
                                            <input type="text" class="form-control"
                                                   value="<{$message_config.accountSid}>"
                                                   placeholder="请输入 accountSid 配置参数" id="txtaccountsid_msg">
                                        </div>
                                    </div>
                                    <div class="form-group">
                                        <label class="col-sm-2 control-label">accountToken</label>
                                        <div class="col-sm-9">
                                            <input type="text" class="form-control"
                                                   value="<{$message_config.accountToken}>"
                                                   placeholder="请输入 accountToken 配置参数" id="txtaccounttoken_msg">
                                        </div>
                                    </div>
                                    <div class="form-group">
                                        <label class="col-sm-2 control-label">appId</label>
                                        <div class="col-sm-9">
                                            <input type="text" class="form-control" value="<{$message_config.appId}>"
                                                   placeholder="请输入 appId 配置参数" id="txtappid_msg">
                                        </div>
                                    </div>
                                    <div class="form-group">
                                        <label class="col-sm-2 control-label">模板ID</label>
                                        <div class="col-sm-9">
                                            <input type="text" class="form-control" value="<{$message_config.modelId}>"
                                                   placeholder="请输入 短信模板ID" id="txtmodelid_msg">
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-2 control-label">声网配置参数</label>
                            <div class="col-sm-10">
                                <div style="padding: 15px 0; border:1px solid #cfdadd;">
                                    <div class="form-group">
                                        <label class="col-sm-2 control-label">appCertificate</label>
                                        <div class="col-sm-9">
                                            <input type="text" class="form-control"
                                                   value="<{$agora_config.appCertificate}>"
                                                   placeholder="请输入 appCertificate 配置参数" id="txtappcertificate_agora">
                                        </div>
                                    </div>
                                    <div class="form-group">
                                        <label class="col-sm-2 control-label">appId</label>
                                        <div class="col-sm-9">
                                            <input type="text" class="form-control" value="<{$agora_config.appId}>"
                                                   placeholder="请输入 appId 配置参数" id="txtappid_agora">
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </div>

                        <div class="form-group">
                            <label class="col-sm-2 control-label">苹果版本管理</label>
                            <div class="col-sm-10">
                                <div style="padding: 15px 0; border:1px solid #cfdadd;">
                                    <div class="form-group">
                                        <label class="col-sm-2 control-label">强制更新</label>
                                        <div class="col-sm-9">
                                            <select class="form-control" id="ddliosswitch">
                                                <volist name="ios_app_update_arr" id="ios_app_update_arr">
                                                    <option value="<{$ios_app_update_arr.value}>"
                                                    <{$ios_app_update_arr.switch_selected}>><{$ios_app_update_arr.text}></option>
                                                </volist>
                                            </select>
                                        </div>
                                    </div>
                                    <div class="form-group">
                                        <label class="col-sm-2 control-label">版本号</label>
                                        <div class="col-sm-9">
                                            <input type="text" class="form-control"
                                                   value="<{$ios_version.version}>"
                                                   placeholder="请输入 苹果版本号" id="ios_version">
                                        </div>
                                    </div>

                                    <div class="form-group">
                                        <label class="col-sm-2 control-label">更新地址</label>
                                        <div class="col-sm-9">
                                            <input type="text" class="form-control" value="<{$ios_version.url}>"
                                                   placeholder="请输入 苹果更新地址" id="ios_url">
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-2 control-label">安卓版本管理</label>
                            <div class="col-sm-10">
                                <div style="padding: 15px 0; border:1px solid #cfdadd;">
                                    <div class="form-group">
                                        <label class="col-sm-2 control-label">强制更新</label>
                                        <div class="col-sm-9">
                                            <select class="form-control" id="ddlandroidswitch">

                                                <volist name="android_app_update_arr" id="android_app_update_arr">
                                                    <option value="<{$android_app_update_arr.value}>"
                                                    <{$android_app_update_arr.switch_selected}>><{$android_app_update_arr.text}></option>
                                                </volist>
                                            </select>
                                        </div>
                                    </div>
                                    <div class="form-group">
                                        <label class="col-sm-2 control-label">版本号</label>
                                        <div class="col-sm-9">
                                            <input type="text" class="form-control"
                                                   value="<{$android_version.version}>"
                                                   placeholder="请输入 安卓版本号" id="android_version">
                                        </div>
                                    </div>

                                    <div class="form-group">
                                        <label class="col-sm-2 control-label">更新地址</label>
                                        <div class="col-sm-9">
                                            <input type="text" class="form-control"
                                                   value="<{$android_version.url}>"
                                                   placeholder="请输入 安卓更新地址" id="android_url">
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </div>
                        <div class="hr-line-dashed"></div>
                        <div class="form-group">
                            <div class="col-sm-4 col-sm-offset-2">
                                <button class="btn btn-primary" type="button" onclick="system_submit(this)">保存</button>
                                &nbsp;&nbsp;&nbsp;
                                <button class="btn btn-white" type="reset">重置</button>
                            </div>
                        </div>
                    </form>
                </div>
            </div>
        </div>
    </div>
</div>
<!--  全局js -->
<script src="__PUBLIC__/js/jquery.min.js?v=2.1.4"></script>
<script src="__PUBLIC__/js/bootstrap.min.js?v=3.3.6"></script>
<!-- 自定义js -->
<script src="__PUBLIC__/js/content.js?v=1.0.0"></script>
<script src="__PUBLIC__/js/plugins/layer/layer.min.js"></script>
<script src="__PUBLIC__/js/liandong.js"></script>
<script src="__PUBLIC__/js/ajaxfileupload.js"></script>
<script src="__PUBLIC__/Widget/webuploader/0.1.5/webuploader.min.js"></script>
<!--这里加载的语言文件会覆盖你在配置项目里添加的语言类型，比如你在配置项目里配置的是英文，这里加载的中文，那最后就是中文-->
<script>
    var imguploadsubmit = "<{:U('imgupload','','shtml')}>";
    var systemsubmit = "<{:U('systemsubmit','','shtml')}>";
    var system = "<{:U('index','','shtml')}>";
    function check_int(val) {
        return /^[0-9]*$/.test(val) && val.length <= 9;
    }
    function check_float(val) {
        return /^[0-9]+(.[0-9]{2})?$/.test(val) && val.length <= 9;
    }
    var $logoimg = $("#logoimg");
    var $logosrc = $("#logosrc");
    var $form_group = $(".form-group:visible");
    var $txt_int = $form_group.find(".int");
    var $txt_float = $form_group.find(".float");
    $logoimg.change("propertychange", function () {
        ajaxFileUpload();
    });
    $txt_int.blur(function () {
        var val = $(this).val();
        if (val != "" && !check_int(val)) {
            layer.alert('无效的内容！\r\n', {title: '提示框', icon: 0});
            return false;
        }
    });
    $txt_float.blur(function () {
        var val = $(this).val();
        if (val != "" && !check_float(val)) {
            layer.alert('无效的内容！\r\n', {title: '提示框', icon: 0});
            return false;
        }
    });
    function system_submit(obj) {
        var $obj = $(obj);
        var $txtratio = $('#txtratio');
        var $logosrc = $("#logosrc");
        var $txtinviteword = $('#txtinviteword');
        var $txtinitgold = $('#txtinitgold');
        var $txtinvitegold = $('#txtinvitegold');
        var $txtmessagegold = $('#txtmessagegold');
        var $txtvideogold = $('#txtvideogold');
        var $txtfreecumulative = $('#txtfreecumulative');
        var $ddlimgsidswitch = $('#ddlimgsidswitch');
        var $ddlvideoswitch = $('#ddlvideoswitch');
        var $ddlqqswitch = $('#ddlqqswitch');
        var $ddlwxswitch = $('#ddlwxswitch');
        var $txtaccountsid_msg = $('#txtaccountsid_msg');
        var $txtaccounttoken_msg = $('#txtaccounttoken_msg');
        var $txtappid_msg = $('#txtappid_msg');
        var $txtmodelid_msg = $('#txtmodelid_msg');
        var $txtappcertificate_agora = $('#txtappcertificate_agora');
        var $txtappid_agora = $('#txtappid_agora');
        var $txtversion = $('#txtversion');
        var $txtshare_ratio=$('#txtshare_ratio');
        var id = "<{$id}>";
        var ratio = $txtratio.val();
        var imgdefault = $logosrc.val();
        var inviteword = $txtinviteword.val();
        var initgold = $txtinitgold.val();
        var invitegold = $txtinvitegold.val();
        var messagegold = $txtmessagegold.val();
        var videogold = $txtvideogold.val();
        var freecumulative = $txtfreecumulative.val();
        var imgsidswitch = $ddlimgsidswitch.val();
        var videoswitch = $ddlvideoswitch.val();
        var qqswitch = $ddlqqswitch.val();
        var wxswitch = $ddlwxswitch.val();
        var accountsid_msg = $txtaccountsid_msg.val();
        var accounttoken_msg = $txtaccounttoken_msg.val();
        var appid_msg = $txtappid_msg.val();
        var modelid_msg = $txtmodelid_msg.val();
        var appcertificate_agora = $txtappcertificate_agora.val();
        var appid_agora = $txtappid_agora.val();
        var share_ratio = $txtshare_ratio.val();
//        var version = $txtversion.val();


        var ddliosswitch = $('#ddliosswitch').val();
        var ios_version = $('#ios_version').val();
        var ios_url = $('#ios_url').val();


        var ddlandroidswitch = $('#ddlandroidswitch').val();
        var android_version = $('#android_version').val();
        var android_url = $('#android_url').val();

        if (ratio != "" && !check_int(ratio)) {
            layer.alert('无效的金币换算值！\r\n', {title: '提示框', icon: 0});
            return false;
        }
        if (share_ratio != "" && !check_int(share_ratio)) {
            layer.alert('无效的分享收益比例！\r\n', {title: '提示框', icon: 0});
            return false;
        }
        if (initgold != "" && !check_int(initgold)) {
            layer.alert('无效的注册赠送金币！\r\n', {title: '提示框', icon: 0});
            return false;
        }
        if (invitegold != "" && !check_int(invitegold)) {
            layer.alert('无效的邀请赠送金币！\r\n', {title: '提示框', icon: 0});
            return false;
        }
        if (messagegold != "" && !check_int(messagegold)) {
            layer.alert('无效的消息发送价格！\r\n', {title: '提示框', icon: 0});
            return false;
        }
        if (videogold != "" && !check_int(videogold)) {
            layer.alert('无效的视频通话价格！\r\n', {title: '提示框', icon: 0});
            return false;
        }
        if (freecumulative != "" && !check_int(freecumulative)) {
            layer.alert('无效的月满免金额！\r\n', {title: '提示框', icon: 0});
            return false;
        }
//						$obj.html('保存中…').removeClass('btn-primary').unbind('click').removeAttr('onclick');
        layer.confirm('确定保存当前设置吗？', function (index) {
            layer.close(index);
            //加载loading层
            var loading = layer.load(1, {
                shade: [0.1, '#fff'] //0.1透明度的白色背景
            });
            $.post(systemsubmit, {
                    'id': id,
                    'ratio': ratio,
                    'imgdefault': imgdefault,
                    'inviteword': inviteword,
                    'initgold': initgold,
                    'invitegold': invitegold,
                    'messagegold': messagegold,
                    'videogold': videogold,
                    'freecumulative' : freecumulative,
                    'videoswitch': videoswitch,
                    'imgsidswitch': imgsidswitch,
                    'qqswitch': qqswitch,
                    'wxswitch': wxswitch,
                    'accountsid_msg': accountsid_msg,
                    'accounttoken_msg': accounttoken_msg,
                    'appid_msg': appid_msg,
                    'modelid_msg': modelid_msg,
                    'appcertificate_agora': appcertificate_agora,
                    'appid_agora': appid_agora,
                    'ddliosswitch': ddliosswitch,
                    'ios_version': ios_version,
                    'ios_url': ios_url,
                    'ddlandroidswitch': ddlandroidswitch,
                    'android_version': android_version,
                    'android_url': android_url,
                    'share_ratio' : share_ratio
                },
                function (data) {
                    if (data.ret == '1001') {
                        layer.msg(data.code, {icon: 6, time: 1000});
                        layer.close(loading);
                        setTimeout(function () {
                            window.location.reload();
                        }, 1000);
                    } else {
                        layer.close(loading);
                        layer.msg(data.code, {icon: 5, time: 1500});
//								    $obj.html('保存').addClass('btn-primary').attr('onclick', 'system_submit(this)');
                    }
                }, 'json');
        });
    }
    function ajaxFileUpload() {
        $.ajaxFileUpload({
            url: imguploadsubmit, //你处理上传文件的服务端
            secureuri: false, //与页面处理代码中file相对应的ID值
            fileElementId: 'logoimg',
            dataType: 'JSON', //返回数据类型:TEXT，XML，JSON，HTML，SCRIPT，JSONP五种
            success: function (data, status) {
                var $inputfileimg = $("#inputfile-img");
                var $logosrc = $("#logosrc");
                var $logoimg = $("#logoimg");
                data = $(data).text();
                data = data.substring(0, data.indexOf('}') + 1);
                data = eval("(" + data + ")");
                if (data.ret == '1001') {
                    layer.msg(data.code, {icon: 6, time: 1000});
                    $inputfileimg.removeClass('img_default').addClass('img').attr('src', data.data);
                    $logosrc.val(data.data);
                } else {
                    layer.msg(data.code, {icon: 5, time: 1500});
                }
                $logoimg.change("propertychange", function () {//再次绑定
                    ajaxFileUpload();
                });
            },
            error: function (data, status, e) {
                alert(status);
            }
        });
        return false;
    }

</script>
</body>
</html>
